﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

using pdftron.PDF.Tools;

// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236

namespace CompleteReader.Dialogs
{
    public sealed partial class AnnotationToolbarDialog : CloseableDialog
    {

        private ToolManager _ToolManager = null;
        public ToolManager ToolManager
        {
            get { return _ToolManager; }
            set 
            { 
                _ToolManager = value;
                this.AnnotationToolbar.ToolManager = _ToolManager;
            }
        }

        public bool ButtonsStayDown
        {
            get { return this.AnnotationToolbar.ButtonsStayDown; }
            set { this.AnnotationToolbar.ButtonsStayDown = value; }
        }

        public AnnotationToolbarDialog()
        {
            this.InitializeComponent();
            this.AnnotationToolbar.ControlClosed += AnnotationToolbar_ControlClosed;
            this.AnnotationToolbar.ButtonsStayDown = true; //Suren - removed the setting, boardpac doesn't need this //Original code: Settings.Settings.ButtonsStayDown;
        }

        private void AnnotationToolbar_ControlClosed()
        {
            CloseDialog();
        }

        public override void OpenDialog()
        {
            if (_Closed || _Closing)
            {
                this.Visibility = Windows.UI.Xaml.Visibility.Visible;
                _Closing = false;
                _Closed = false;
                _Opening = true;
                _Opened = false;
                SlideInPanel.Begin();
                _ToolManager.CreateTool(ToolType.e_pan, null);
            }
        }

        private void SlideInCompleted(object sender, object e)
        {
            base.OpenDialog();
        }


        public override void CloseDialog()
        {
            if (_Opened || _Opening)
            {
                _Closing = true;
                _Closed = false;
                _Opening = false;
                _Opened = false;
                SlideOutPanel.Begin();
            }
        }

        private void SlideOutCompleted(object sender, object e)
        {
            base.CloseDialog();
        }


    }
}
